-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
Design NotesNotes from our design meetingsNotes from our design meetings
Description
- Preface: Obligatory "is that you climbing the rock" joke about Daniel's wallpaper.
TC39 Updates
- TC39 update
globalThisto stage 4- New in stage 3:
Promise.any,String#replaceAll, formalized for-in object iteration - New in stage 2:
Map#upsert - New in stage 1: A bunch of stuff
- Readonly collections
- Records and tuples
#{ x: 0 }
Optional Chaining and Narrowing
-
Have been iterating on feedback around narrowing optional chaining.
-
type Header = { headers: Record<string, any> }; type Options = { config : any }; function getHeader(input: Header | Options, key: string, def?: any) { return ('headers' in input ? input.headers [key] : undefined) || def; }
-
Today,
inadds a property to the original type. -
type Header = { headers: Record<string, any> }; type Options = { config: any }; function getHeader(input: Header | Options, key: string, def?: any) { return input.headers?.[key] ?? def; }
-
Uhh.
Correcting Loose Assignability Rules for Intersections to Index Signatures
declare let s: { a: string } & { b: string };
declare let t: { [key: string]: string };
t = s;- Our assignability rules say that if any constituent of an intersection is assignable to an index signature, the types are assignable.
- UHH.
- Happens when you work on dictionary-like objects.
- We don't have a concrete rule yet, but have been observing some pain.
- Technically even
{ a: string }being assignable toRecord<string, string>is wrong because{ a: string }can contain more properties than it declares.- Otherwise it would be extremely difficult to deal with dictionary-like bags of properties.
- Probably 3.8-bound at earliest.
devDependencies in @types Packages
- Problem: today, an app can't have both
@types/nodeand@types/react-nativein the same dependency tree.- This is because they both define globals.
- Solution 1: "Just let them coincide"?
- Solution 2: Give a blessed configuration for web and for react native?
- Solution 3: Be careful about the
@typesin your dependency trees. - But then other problems...
- Problem: a library that wraps both
reactandreact-nativecomponents can't have a dependency on either!- Proposed solution in Allow using dev dependencies in a package json types-publisher#655:
devDependencyspecifies that a package works with these packages,- Adding these as
devDependencys means that you can't use types from these in output positions.
- Adding these as
- Proposed solution in Allow using dev dependencies in a package json types-publisher#655:
- The whole situation is a mess: react depends on react-dom, react-native depends on react, some of these APIs use
Buffers when you're in Node. - What about a forward-declaration mechanism?
- Are there libraries with these problems in DefinitelyTyped otherwise?
- Yes!
- With Placeholder Type Declarations #31894, is the idea that you just say "there's a Buffer"?
- Yes, "don't care what it is, but I'll take one!"
- Anything else you can't do with interfaces instead of forward declarations?
- Well you can't forward-declare a type alias to a union type or tuple.
IteratorResultended up with this issue, meant we needed to dotypesVersions.
- What happened last time we chatted about placeholder types?
- Tried to see if we could break the feature down into different functionality.
- What about conditional inclusion?
- Something like type polyfills?
- Swift potentially has something like this.
- But how do you explore versioning?
- Feels like this has turned into a discussion about many different problems.
- Original problem:
devDependencyto check on DefinitelyTyped, let users install the correct peer types.
- Original problem:
- Does this stand up to other future solutions?
- Unclear if this paints us into a corner.
- How do you tell users "you have to also install
@types/nodenow"?
- Also, there's an
excludeTypes(Placeholder Type Declarations #31894) - a way to say "no, please don't add@types/nodefrom being included".- But someone asked for those types to be included indirectly.
- Aside: .NET has had this problem since...forever and solved it with...not working correctly? :(
- What if
@typespackages could fulfulllibsettings, and then we could providelib? - Conclusion: We will scope down and isolate the concerns in a separate meeting.
- Also, of all the types that rely on
@types/node, what do they rely on?
- Also, of all the types that rely on
svieira, Jessidhia, Bnaya, dragomirtitian and alexanderjarvisAnyhowStep, svieira, saschanaz and Jessidhia
Metadata
Metadata
Assignees
Labels
Design NotesNotes from our design meetingsNotes from our design meetings