Comments (5)
I guess what I don’t understand is, if you’re already capable of doing this check for an arbitrary expression in the something position, what does the extra syntax buy you? It just feels like noise then.
Given
// @filename: node_modules/mod/index.ts
export const something = Math.random() ? 1 : 2;
then
import {something} from "mod";
export const a = {[something]: 1};
has no errors, while
import {something} from "mod";
export const a = {[something satisfies keyof]: 1};
issues an error on something
: A satisfies keyof computed property name must be exactly a single string, number, or unique symbol literal type
.
and
import {something} from "mod";
export const a = {[something]: 1};
emits
export const a: {[something: number]: number};
in accordance with the type of the resolved something
, but
import {something} from "mod";
export const a = {[something satisfies keyof]: 1};
always emits, even if something
cannot be resolved:
import {something} from "mod";
export const a: {[something]: number};
from typescript.
It's basically a way to pull the error the declaration file would get from preserving the computed property name forward into the input file.
from typescript.
… and issue an error on something satisfies keyof if something isn't exactly a single unique symbol, string literal, or number literal type (as is valid in the type position computed property name).
I guess what I don’t understand is, if you’re already capable of doing this check for an arbitrary expression in the something
position, what does the extra syntax buy you? It just feels like noise then.
from typescript.
Ah, so it's basically a syntactic hint not to widen it to an index signature, we always want it to show up as a computed property in types. satisfies keyof
being that hint feels really awkward and non-intuitive, but that's strictly in 🚲 🏠 territory which it's probably too early for.
from typescript.
Since Symbol.iterator
is called out here, I just wanted to throw Symbol.asyncIterator
into the ring because I didn't see it mentioned anywhere else and also produces an error currently.
from typescript.
Related Issues (20)
- JSDoc @import _unintentional?_ passthrough to generated declarations.
- Crashes on transform and parse (from assertion/debug failures) HOT 4
- Object circular assignment never error HOT 2
- Only resolve source return type when actually needed during inference when generic is used HOT 2
- Target signature provides too few arguments. Expected 1 or more, but got 0 HOT 1
- Convert params to destructed object: Cannot apply refactoring HOT 2
- getPasteEdits returns edits even when no imports are added
- getPasteEdits returns wrong range for primary edit
- Some long function return expressions no longer evaluated in 5.5 HOT 3
- Generic is "`any`-like" for relational operators HOT 4
- inherit interface/type block comment HOT 2
- JSDoc: property access within static initialization block of @extends annotated class from different file
- Isolated Declarations in TS 5.5: State of the feature
- Isolated declarations quick fix suggests `boolean` return type for predicates HOT 2
- Is the "Roadmap" wiki page still maintained? HOT 3
- Typescript 5.5 is not working with yarn v4 and nodeLinker pnp, it forces switching to nodeLinker node-modules HOT 4
- update Object.values and Object.entries docs to mention they look only at own properties HOT 1
- `@import` JSDoc tag doesn't seem to account for `resolution-mode` import attribute in TS v5.5.2 HOT 1
- `/// <reference lib` is stripped out of `d.ts` file HOT 2
- HookWebpackError: Maximum call stack size exceeded in Release 5.5.2 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from typescript.