-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
UMD support #7264
Merged
Merged
UMD support #7264
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
44aa738
UMD support
RyanCavanaugh e9f4bef
Address CR feedback
RyanCavanaugh 887adb0
Move checks from checker to binder
RyanCavanaugh 34cf105
Lint
RyanCavanaugh 132d75c
Support UMD when targeted module uses `export = `
RyanCavanaugh 3d948be
Support module augmentation
RyanCavanaugh 2875326
Use existing function to resolve export= declarations
RyanCavanaugh 14941f2
Add tests for each variant of UMD augmentation
RyanCavanaugh c72f1c3
Reuse existing var
RyanCavanaugh 8cef251
Add test for function export
RyanCavanaugh 043b338
Add `export = class` scenario
RyanCavanaugh 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 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 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 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 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 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 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 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 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 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 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,50 @@ | ||
//// [tests/cases/conformance/externalModules/umd-augmentation-1.ts] //// | ||
|
||
//// [index.d.ts] | ||
|
||
export as namespace Math2d; | ||
|
||
export interface Point { | ||
x: number; | ||
y: number; | ||
} | ||
|
||
export class Vector implements Point { | ||
x: number; | ||
y: number; | ||
constructor(x: number, y: number); | ||
|
||
translate(dx: number, dy: number): Vector; | ||
} | ||
|
||
export function getLength(p: Vector): number; | ||
|
||
//// [math2d-augment.d.ts] | ||
import * as Math2d from 'math2d'; | ||
// Augment the module | ||
declare module 'math2d' { | ||
// Add a method to the class | ||
interface Vector { | ||
reverse(): Math2d.Point; | ||
} | ||
} | ||
|
||
//// [b.ts] | ||
/// <reference path="math2d-augment.d.ts" /> | ||
import * as m from 'math2d'; | ||
let v = new m.Vector(3, 2); | ||
let magnitude = m.getLength(v); | ||
let p: m.Point = v.translate(5, 5); | ||
p = v.reverse(); | ||
var t = p.x; | ||
|
||
|
||
//// [b.js] | ||
"use strict"; | ||
/// <reference path="math2d-augment.d.ts" /> | ||
var m = require('math2d'); | ||
var v = new m.Vector(3, 2); | ||
var magnitude = m.getLength(v); | ||
var p = v.translate(5, 5); | ||
p = v.reverse(); | ||
var t = p.x; |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little bit of documentation on this would be helpful. From a cursory glance, it doesn't seem obvious that this is differentiated from an import.
Alternatively, make an enum.