forked from microsoft/TypeScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
import statement from "node" in js source file could produce correct …
…declaration path. (microsoft#41816) * fix microsoft#41800 * add test * fix test
- Loading branch information
1 parent
7120f70
commit 031ec5c
Showing
5 changed files
with
139 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
40 changes: 40 additions & 0 deletions
40
tests/baselines/reference/importDeclFromTypeNodeInJsSource.js
This file contains 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,40 @@ | ||
//// [tests/cases/compiler/importDeclFromTypeNodeInJsSource.ts] //// | ||
|
||
//// [index.d.ts] | ||
/// <reference path="events.d.ts" /> | ||
//// [events.d.ts] | ||
declare module "events" { | ||
namespace EventEmitter { | ||
class EventEmitter { | ||
constructor(); | ||
} | ||
} | ||
export = EventEmitter; | ||
} | ||
|
||
//// [b.js] | ||
import { EventEmitter } from 'events'; | ||
class Foo extends EventEmitter { | ||
constructor() { | ||
super(); | ||
} | ||
} | ||
export default Foo; | ||
|
||
//// [b.js] | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const events_1 = require("events"); | ||
class Foo extends events_1.EventEmitter { | ||
constructor() { | ||
super(); | ||
} | ||
} | ||
exports.default = Foo; | ||
|
||
|
||
//// [b.d.ts] | ||
export default Foo; | ||
declare class Foo extends EventEmitter { | ||
} | ||
import { EventEmitter } from "events"; |
35 changes: 35 additions & 0 deletions
35
tests/baselines/reference/importDeclFromTypeNodeInJsSource.symbols
This file contains 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,35 @@ | ||
=== /src/node_modules/@types/node/index.d.ts === | ||
/// <reference path="events.d.ts" /> | ||
No type information for this code.=== /src/node_modules/@types/node/events.d.ts === | ||
declare module "events" { | ||
>"events" : Symbol("events", Decl(events.d.ts, 0, 0)) | ||
|
||
namespace EventEmitter { | ||
>EventEmitter : Symbol(EventEmitter, Decl(events.d.ts, 0, 25)) | ||
|
||
class EventEmitter { | ||
>EventEmitter : Symbol(EventEmitter, Decl(events.d.ts, 1, 28)) | ||
|
||
constructor(); | ||
} | ||
} | ||
export = EventEmitter; | ||
>EventEmitter : Symbol(EventEmitter, Decl(events.d.ts, 0, 25)) | ||
} | ||
|
||
=== /src/b.js === | ||
import { EventEmitter } from 'events'; | ||
>EventEmitter : Symbol(EventEmitter, Decl(b.js, 0, 8)) | ||
|
||
class Foo extends EventEmitter { | ||
>Foo : Symbol(Foo, Decl(b.js, 0, 38)) | ||
>EventEmitter : Symbol(EventEmitter, Decl(b.js, 0, 8)) | ||
|
||
constructor() { | ||
super(); | ||
>super : Symbol(EventEmitter, Decl(events.d.ts, 1, 28)) | ||
} | ||
} | ||
export default Foo; | ||
>Foo : Symbol(Foo, Decl(b.js, 0, 38)) | ||
|
36 changes: 36 additions & 0 deletions
36
tests/baselines/reference/importDeclFromTypeNodeInJsSource.types
This file contains 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,36 @@ | ||
=== /src/node_modules/@types/node/index.d.ts === | ||
/// <reference path="events.d.ts" /> | ||
No type information for this code.=== /src/node_modules/@types/node/events.d.ts === | ||
declare module "events" { | ||
>"events" : typeof import("events") | ||
|
||
namespace EventEmitter { | ||
>EventEmitter : typeof EventEmitter | ||
|
||
class EventEmitter { | ||
>EventEmitter : EventEmitter | ||
|
||
constructor(); | ||
} | ||
} | ||
export = EventEmitter; | ||
>EventEmitter : typeof EventEmitter | ||
} | ||
|
||
=== /src/b.js === | ||
import { EventEmitter } from 'events'; | ||
>EventEmitter : typeof EventEmitter | ||
|
||
class Foo extends EventEmitter { | ||
>Foo : Foo | ||
>EventEmitter : EventEmitter | ||
|
||
constructor() { | ||
super(); | ||
>super() : void | ||
>super : typeof EventEmitter | ||
} | ||
} | ||
export default Foo; | ||
>Foo : Foo | ||
|
This file contains 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,26 @@ | ||
// @target: esnext | ||
// @module: commonjs | ||
// @allowJs: true | ||
// @checkJs: true | ||
// @declaration: true | ||
// @outDir: ./dist | ||
// @filename: /src/node_modules/@types/node/index.d.ts | ||
/// <reference path="events.d.ts" /> | ||
// @filename: /src/node_modules/@types/node/events.d.ts | ||
declare module "events" { | ||
namespace EventEmitter { | ||
class EventEmitter { | ||
constructor(); | ||
} | ||
} | ||
export = EventEmitter; | ||
} | ||
|
||
// @filename: /src/b.js | ||
import { EventEmitter } from 'events'; | ||
class Foo extends EventEmitter { | ||
constructor() { | ||
super(); | ||
} | ||
} | ||
export default Foo; |