Skip to content

Commit 9694fde

Browse files
committed
Use es6-shim for typing and es6-promise to polyfill the promise
1 parent febbe1d commit 9694fde

File tree

8 files changed

+23
-73
lines changed

8 files changed

+23
-73
lines changed

karma.conf.js

+14-17
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ module.exports = function (config) {
22
config.set({
33
frameworks: ["jasmine", "karma-typescript"],
44
files: [
5-
{ pattern: "src/**/*.ts" }, // *.tsx for React Jsx ,
6-
{ pattern: "src/**/*.tsx" }, // *.tsx for React Jsx ,
7-
{ pattern: "test/**/*.ts" }, // *.tsx for React Jsx
8-
{ pattern: "test/**/*.tsx" }, // *.tsx for React Jsx
5+
'./node_modules/phantomjs-polyfill-find/find-polyfill.js',
6+
{ pattern: "src/**/*.ts" },
7+
{ pattern: "src/**/*.tsx" },
8+
{ pattern: "test/**/*.ts" },
9+
{ pattern: "test/**/*.tsx" },
910
],
1011
preprocessors: {
11-
"**/*.ts": ["karma-typescript"], // *.tsx for React Jsx
12-
"**/*.tsx": ["karma-typescript"], // *.tsx for React Jsx
12+
"**/*.ts": ["karma-typescript"],
13+
"**/*.tsx": ["karma-typescript"],
1314
},
1415
reporters: ["spec", "karma-typescript"],
1516
browsers: ["PhantomJS"],
@@ -18,21 +19,17 @@ module.exports = function (config) {
1819
exclude: ["react/addons", "react/lib/ExecutionEnvironment", "react/lib/ReactContext"],
1920
entrypoints: /\.spec\.tsx?$/,
2021
compilerOptions: {
21-
jsx: "react",
22-
module: "commonjs",
2322
sourceMap: true,
24-
target: "ES5",
25-
lib: ["DOM", "ES2015"]
2623
},
2724
include: [
28-
"src/**/*.ts",
29-
"src/**/*.tsx",
25+
"src/**/*.ts",
26+
"src/**/*.tsx",
3027
],
31-
reports:
32-
{
33-
"html": "coverage",
34-
"text-summary": "",
35-
}
28+
reports: {
29+
"html": "coverage",
30+
"text-summary": "",
31+
},
32+
tsconfig: "./tsconfig.json"
3633
}
3734
}
3835
});

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
"devDependencies": {
1212
"@types/classnames": "^0.0.32",
1313
"@types/enzyme": "^2.8.0",
14+
"@types/es6-shim": "^0.31.33",
1415
"@types/history": "^4.5.1",
1516
"@types/jasmine": "^2.5.47",
1617
"@types/node": "^7.0.18",
17-
"@types/es6-promise": "^0.0.32",
1818
"@types/react": "^15.0.24",
1919
"@types/react-dom": "^0.14.23",
2020
"@types/sinon": "^2.2.1",
@@ -37,6 +37,7 @@
3737
"karma-typescript": "^3.0.1",
3838
"node-sass": "^4.5.2",
3939
"path": "^0.12.7",
40+
"phantomjs-polyfill-find": "^0.0.1",
4041
"postcss-browser-reporter": "^0.5.0",
4142
"postcss-cssnext": "^2.10.0",
4243
"postcss-import": "^9.1.0",

sampleapp/index.html

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
</head>
99
<body style="min-height:100%">
1010
<div id="oneNotePicker" style="width:350px;height:350px;margin:50px;overflow-y:scroll"></div>
11-
<script src="dist/polyfills.js"></script>
1211
<script src="dist/sample.js"></script>
1312
</body>
1413
</html>

src/oneNoteDataStructures/notebookListUpdater.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class NotebookListUpdater {
8787
sectionRef.pages = newPages;
8888
}
8989

90-
private getSectionRefFromNotebooks(sectionId: string, notebooks: Notebook[]): Section | void {
90+
private getSectionRefFromNotebooks(sectionId: string, notebooks: Notebook[]): Section | undefined {
9191
for (let notebook of notebooks) {
9292
let sectionRef = this.getSectionRefFromSectionParent(sectionId, notebook);
9393
if (!!sectionRef) {
@@ -99,7 +99,7 @@ class NotebookListUpdater {
9999
return undefined;
100100
}
101101

102-
private getSectionRefFromSectionParent(sectionId: string, sectionParent: SectionParent): Section | void {
102+
private getSectionRefFromSectionParent(sectionId: string, sectionParent: SectionParent): Section | undefined {
103103
// Search this parent's sections for the matching id ...
104104
for (let childSection of sectionParent.sections) {
105105
if (childSection.id === sectionId) {

src/oneNoteDataStructures/section.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ interface Section {
44
id: string;
55
name: string;
66
expanded: boolean;
7-
pages: Page[] | void;
7+
pages: Page[] | undefined;
88
}
99

1010
export default Section;

src/polyfills.ts

-49
This file was deleted.

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"module": "commonjs",
44
"target": "es5",
5-
"lib": ["es6", "dom"],
5+
"lib": ["es5", "dom"],
66
"sourceMap": true,
77
"allowJs": true,
88
"jsx": "react",

webpack.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ module.exports = {
2020
sample: './sampleApp/sample.tsx',
2121
pickerStyles: './src/oneNotePicker.scss',
2222
oneNotePicker: './src/oneNotePicker.tsx',
23-
polyfills: './src/polyfills.ts',
2423
},
2524
output: {
2625
path: outPath,
@@ -110,6 +109,9 @@ module.exports = {
110109
],
111110
},
112111
plugins: [
112+
new webpack.ProvidePlugin({
113+
Promise: 'es6-promise'
114+
}),
113115
// new webpack.LoaderOptionsPlugin({
114116
// options: {
115117
// context: sourcePath,

0 commit comments

Comments
 (0)