-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Adds support for looking up past Blocks in expando objects #38031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
tests/cases/compiler/check.js(22,8): error TS2339: Property 'first' does not exist on type '() => number'. | ||
tests/cases/compiler/check.js(23,8): error TS2339: Property 'last' does not exist on type '() => number'. | ||
tests/cases/compiler/check.js(25,17): error TS2345: Argument of type '() => number' is not assignable to parameter of type 'Human'. | ||
Type '() => number' is missing the following properties from type 'Human': first, last | ||
|
||
|
||
==== tests/cases/compiler/check.ts (0 errors) ==== | ||
// | ||
|
||
|
||
|
||
// https://github.com/microsoft/TypeScript/issues/31972 | ||
interface Person { | ||
first: string; | ||
last: string; | ||
} | ||
|
||
{ | ||
const dice = () => Math.floor(Math.random() * 6); | ||
dice.first = 'Rando'; | ||
dice.last = 'Calrissian'; | ||
const diceP: Person = dice; | ||
} | ||
|
||
==== tests/cases/compiler/check.js (3 errors) ==== | ||
// Creates a type { first:string, last: string } | ||
/** | ||
* @typedef {Object} Human - creates a new type named 'SpecialType' | ||
* @property {string} first - a string property of SpecialType | ||
* @property {string} last - a number property of SpecialType | ||
*/ | ||
|
||
/** | ||
* @param {Human} param used as a validation tool | ||
*/ | ||
function doHumanThings(param) {} | ||
|
||
const dice = () => Math.floor(Math.random() * 6); | ||
dice.first = 'Rando'; | ||
dice.last = 'Calrissian'; | ||
|
||
doHumanThings(dice) | ||
|
||
// but inside a block... you can't call iut a human | ||
{ | ||
const dice = () => Math.floor(Math.random() * 6); | ||
dice.first = 'Rando'; | ||
~~~~~ | ||
!!! error TS2339: Property 'first' does not exist on type '() => number'. | ||
dice.last = 'Calrissian'; | ||
~~~~ | ||
!!! error TS2339: Property 'last' does not exist on type '() => number'. | ||
|
||
doHumanThings(dice) | ||
~~~~ | ||
!!! error TS2345: Argument of type '() => number' is not assignable to parameter of type 'Human'. | ||
!!! error TS2345: Type '() => number' is missing the following properties from type 'Human': first, last | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
=== tests/cases/compiler/check.ts === | ||
// | ||
|
||
|
||
|
||
// https://github.com/microsoft/TypeScript/issues/31972 | ||
orta marked this conversation as resolved.
Show resolved
Hide resolved
|
||
interface Person { | ||
>Person : Symbol(Person, Decl(check.ts, 0, 0)) | ||
|
||
first: string; | ||
>first : Symbol(Person.first, Decl(check.ts, 5, 18)) | ||
|
||
last: string; | ||
>last : Symbol(Person.last, Decl(check.ts, 6, 16)) | ||
} | ||
|
||
{ | ||
const dice = () => Math.floor(Math.random() * 6); | ||
>dice : Symbol(dice, Decl(check.ts, 11, 7)) | ||
>Math.floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) | ||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
|
||
dice.first = 'Rando'; | ||
>dice.first : Symbol(dice.first, Decl(check.ts, 11, 51)) | ||
>dice : Symbol(dice, Decl(check.ts, 11, 7)) | ||
>first : Symbol(dice.first, Decl(check.ts, 11, 51)) | ||
|
||
dice.last = 'Calrissian'; | ||
>dice.last : Symbol(dice.last, Decl(check.ts, 12, 23)) | ||
>dice : Symbol(dice, Decl(check.ts, 11, 7)) | ||
>last : Symbol(dice.last, Decl(check.ts, 12, 23)) | ||
|
||
const diceP: Person = dice; | ||
>diceP : Symbol(diceP, Decl(check.ts, 14, 7)) | ||
>Person : Symbol(Person, Decl(check.ts, 0, 0)) | ||
>dice : Symbol(dice, Decl(check.ts, 11, 7)) | ||
} | ||
|
||
=== tests/cases/compiler/check.js === | ||
// Creates a type { first:string, last: string } | ||
/** | ||
* @typedef {Object} Human - creates a new type named 'SpecialType' | ||
* @property {string} first - a string property of SpecialType | ||
* @property {string} last - a number property of SpecialType | ||
*/ | ||
|
||
/** | ||
* @param {Human} param used as a validation tool | ||
*/ | ||
function doHumanThings(param) {} | ||
>doHumanThings : Symbol(doHumanThings, Decl(check.js, 0, 0)) | ||
>param : Symbol(param, Decl(check.js, 10, 23)) | ||
|
||
const dice = () => Math.floor(Math.random() * 6); | ||
>dice : Symbol(dice, Decl(check.js, 12, 5), Decl(check.js, 12, 49), Decl(check.js, 13, 21)) | ||
>Math.floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) | ||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
|
||
dice.first = 'Rando'; | ||
>dice.first : Symbol(dice.first, Decl(check.js, 12, 49), Decl(check.js, 20, 51)) | ||
>dice : Symbol(dice, Decl(check.js, 12, 5), Decl(check.js, 12, 49), Decl(check.js, 13, 21)) | ||
>first : Symbol(dice.first, Decl(check.js, 12, 49), Decl(check.js, 20, 51)) | ||
|
||
dice.last = 'Calrissian'; | ||
>dice.last : Symbol(dice.last, Decl(check.js, 13, 21), Decl(check.js, 21, 23)) | ||
>dice : Symbol(dice, Decl(check.js, 12, 5), Decl(check.js, 12, 49), Decl(check.js, 13, 21)) | ||
>last : Symbol(dice.last, Decl(check.js, 13, 21), Decl(check.js, 21, 23)) | ||
|
||
doHumanThings(dice) | ||
>doHumanThings : Symbol(doHumanThings, Decl(check.js, 0, 0)) | ||
>dice : Symbol(dice, Decl(check.js, 12, 5), Decl(check.js, 12, 49), Decl(check.js, 13, 21)) | ||
|
||
// but inside a block... you can't call iut a human | ||
{ | ||
const dice = () => Math.floor(Math.random() * 6); | ||
>dice : Symbol(dice, Decl(check.js, 20, 7)) | ||
>Math.floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>floor : Symbol(Math.floor, Decl(lib.es5.d.ts, --, --)) | ||
>Math.random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
>Math : Symbol(Math, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --)) | ||
>random : Symbol(Math.random, Decl(lib.es5.d.ts, --, --)) | ||
|
||
dice.first = 'Rando'; | ||
>dice : Symbol(dice, Decl(check.js, 20, 7)) | ||
|
||
dice.last = 'Calrissian'; | ||
>dice : Symbol(dice, Decl(check.js, 20, 7)) | ||
|
||
doHumanThings(dice) | ||
>doHumanThings : Symbol(doHumanThings, Decl(check.js, 0, 0)) | ||
>dice : Symbol(dice, Decl(check.js, 20, 7)) | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
=== tests/cases/compiler/check.ts === | ||
// | ||
|
||
|
||
|
||
// https://github.com/microsoft/TypeScript/issues/31972 | ||
interface Person { | ||
first: string; | ||
>first : string | ||
|
||
last: string; | ||
>last : string | ||
} | ||
|
||
{ | ||
const dice = () => Math.floor(Math.random() * 6); | ||
>dice : { (): number; first: string; last: string; } | ||
>() => Math.floor(Math.random() * 6) : { (): number; first: string; last: string; } | ||
>Math.floor(Math.random() * 6) : number | ||
>Math.floor : (x: number) => number | ||
>Math : Math | ||
>floor : (x: number) => number | ||
>Math.random() * 6 : number | ||
>Math.random() : number | ||
>Math.random : () => number | ||
>Math : Math | ||
>random : () => number | ||
>6 : 6 | ||
|
||
dice.first = 'Rando'; | ||
>dice.first = 'Rando' : "Rando" | ||
>dice.first : string | ||
>dice : { (): number; first: string; last: string; } | ||
>first : string | ||
>'Rando' : "Rando" | ||
|
||
dice.last = 'Calrissian'; | ||
>dice.last = 'Calrissian' : "Calrissian" | ||
>dice.last : string | ||
>dice : { (): number; first: string; last: string; } | ||
>last : string | ||
>'Calrissian' : "Calrissian" | ||
|
||
const diceP: Person = dice; | ||
>diceP : Person | ||
>dice : { (): number; first: string; last: string; } | ||
} | ||
|
||
=== tests/cases/compiler/check.js === | ||
// Creates a type { first:string, last: string } | ||
/** | ||
* @typedef {Object} Human - creates a new type named 'SpecialType' | ||
* @property {string} first - a string property of SpecialType | ||
* @property {string} last - a number property of SpecialType | ||
*/ | ||
|
||
/** | ||
* @param {Human} param used as a validation tool | ||
*/ | ||
function doHumanThings(param) {} | ||
>doHumanThings : (param: Human) => void | ||
>param : Human | ||
|
||
const dice = () => Math.floor(Math.random() * 6); | ||
>dice : { (): number; first: string; last: string; } | ||
>() => Math.floor(Math.random() * 6) : { (): number; first: string; last: string; } | ||
>Math.floor(Math.random() * 6) : number | ||
>Math.floor : (x: number) => number | ||
>Math : Math | ||
>floor : (x: number) => number | ||
>Math.random() * 6 : number | ||
>Math.random() : number | ||
>Math.random : () => number | ||
>Math : Math | ||
>random : () => number | ||
>6 : 6 | ||
|
||
dice.first = 'Rando'; | ||
>dice.first = 'Rando' : "Rando" | ||
>dice.first : string | ||
>dice : { (): number; first: string; last: string; } | ||
>first : string | ||
>'Rando' : "Rando" | ||
|
||
dice.last = 'Calrissian'; | ||
>dice.last = 'Calrissian' : "Calrissian" | ||
>dice.last : string | ||
>dice : { (): number; first: string; last: string; } | ||
>last : string | ||
>'Calrissian' : "Calrissian" | ||
|
||
doHumanThings(dice) | ||
>doHumanThings(dice) : void | ||
>doHumanThings : (param: Human) => void | ||
>dice : { (): number; first: string; last: string; } | ||
|
||
// but inside a block... you can't call iut a human | ||
{ | ||
const dice = () => Math.floor(Math.random() * 6); | ||
>dice : () => number | ||
>() => Math.floor(Math.random() * 6) : () => number | ||
>Math.floor(Math.random() * 6) : number | ||
>Math.floor : (x: number) => number | ||
>Math : Math | ||
>floor : (x: number) => number | ||
>Math.random() * 6 : number | ||
>Math.random() : number | ||
>Math.random : () => number | ||
>Math : Math | ||
>random : () => number | ||
>6 : 6 | ||
|
||
dice.first = 'Rando'; | ||
>dice.first = 'Rando' : "Rando" | ||
>dice.first : any | ||
>dice : () => number | ||
>first : any | ||
>'Rando' : "Rando" | ||
|
||
dice.last = 'Calrissian'; | ||
>dice.last = 'Calrissian' : "Calrissian" | ||
>dice.last : any | ||
>dice : () => number | ||
>last : any | ||
>'Calrissian' : "Calrissian" | ||
|
||
doHumanThings(dice) | ||
>doHumanThings(dice) : void | ||
>doHumanThings : (param: Human) => void | ||
>dice : () => number | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// https://github.com/microsoft/TypeScript/issues/31972 | ||
|
||
// @allowJs: true | ||
// @noEmit: true | ||
// @checkJs: true | ||
|
||
// @filename: check.ts | ||
|
||
// https://github.com/microsoft/TypeScript/issues/31972 | ||
interface Person { | ||
first: string; | ||
last: string; | ||
} | ||
|
||
{ | ||
const dice = () => Math.floor(Math.random() * 6); | ||
dice.first = 'Rando'; | ||
dice.last = 'Calrissian'; | ||
const diceP: Person = dice; | ||
} | ||
|
||
// @filename: check.js | ||
|
||
// Creates a type { first:string, last: string } | ||
/** | ||
* @typedef {Object} Human - creates a new type named 'SpecialType' | ||
* @property {string} first - a string property of SpecialType | ||
* @property {string} last - a number property of SpecialType | ||
*/ | ||
|
||
/** | ||
* @param {Human} param used as a validation tool | ||
*/ | ||
function doHumanThings(param) {} | ||
|
||
const dice = () => Math.floor(Math.random() * 6); | ||
dice.first = 'Rando'; | ||
dice.last = 'Calrissian'; | ||
|
||
doHumanThings(dice) | ||
|
||
// but inside a block... you can't call iut a human | ||
{ | ||
const dice = () => Math.floor(Math.random() * 6); | ||
dice.first = 'Rando'; | ||
dice.last = 'Calrissian'; | ||
|
||
doHumanThings(dice) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.