mirror of
https://github.com/flarum/core.git
synced 2025-08-05 16:07:34 +02:00
TS: Merge shims and tsconfig for now
This makes the structure less confusing, as long as the two parts are not needed. Once we actually have decided where to move the shared parts (to share them with bundled and community extensions), and which parts to share, this can easily be extracted again.
This commit is contained in:
44
js/shims.d.ts
vendored
44
js/shims.d.ts
vendored
@@ -1,13 +1,47 @@
|
|||||||
// Use shared globals from flarum-webpack-config
|
// Mithril
|
||||||
// TEMPORARY: This will likely move to the flarum-webpack-config package.
|
import * as Mithril from 'mithril';
|
||||||
export * from './webpack-config-shims';
|
import Stream from 'mithril/stream';
|
||||||
|
|
||||||
|
// Other third-party libs
|
||||||
|
import * as _dayjs from 'dayjs';
|
||||||
|
import * as _$ from 'jquery';
|
||||||
|
|
||||||
|
// Globals from flarum/core
|
||||||
import Application from './src/common/Application';
|
import Application from './src/common/Application';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotate the types of all global variables specific to flarum/core.
|
* Helpers that flarum/core patches into Mithril
|
||||||
|
*/
|
||||||
|
interface m extends Mithril.Static {
|
||||||
|
prop: typeof Stream;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export Mithril typings globally.
|
||||||
*
|
*
|
||||||
* IDEs can use this to typehint the globals.
|
* This lets us use these typings without an extra import everywhere we use
|
||||||
|
* Mithril in a TypeScript file.
|
||||||
|
*/
|
||||||
|
export as namespace Mithril;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* flarum/core exposes several extensions globally:
|
||||||
|
*
|
||||||
|
* - jQuery for convenient DOM manipulation
|
||||||
|
* - Mithril for VDOM and components
|
||||||
|
* - dayjs for date/time operations
|
||||||
|
*
|
||||||
|
* Since these are already part of the global namespace, extensions won't need
|
||||||
|
* to (and should not) bundle these themselves.
|
||||||
|
*/
|
||||||
|
declare global {
|
||||||
|
const $: typeof _$;
|
||||||
|
const m: m;
|
||||||
|
const dayjs: typeof _dayjs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All global variables owned by flarum/core.
|
||||||
*/
|
*/
|
||||||
declare global {
|
declare global {
|
||||||
const app: Application;
|
const app: Application;
|
||||||
|
@@ -1,3 +1,21 @@
|
|||||||
{
|
{
|
||||||
"extends": "./webpack-config-tsconfig"
|
"include": ["src/**/*.ts"],
|
||||||
|
"files": ["shims.d.ts"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowUmdGlobalAccess": true,
|
||||||
|
"outDir": "dist",
|
||||||
|
"sourceMap": true,
|
||||||
|
"strict": true,
|
||||||
|
"noImplicitReturns": false,
|
||||||
|
"noImplicitAny": false,
|
||||||
|
"module": "es2015",
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"target": "es6",
|
||||||
|
"jsx": "preserve",
|
||||||
|
"lib": ["es2015", "es2017", "dom"],
|
||||||
|
"allowSyntheticDefaultImports": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
36
js/webpack-config-shims.d.ts
vendored
36
js/webpack-config-shims.d.ts
vendored
@@ -1,36 +0,0 @@
|
|||||||
import * as Mithril from 'mithril';
|
|
||||||
import Stream from 'mithril/stream';
|
|
||||||
|
|
||||||
import * as _dayjs from 'dayjs';
|
|
||||||
import * as _$ from 'jquery';
|
|
||||||
|
|
||||||
// Helpers that flarum/core patches into Mithril
|
|
||||||
interface m extends Mithril.Static {
|
|
||||||
prop: typeof Stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* flarum/core exposes several extensions globally:
|
|
||||||
*
|
|
||||||
* - jQuery for convenient DOM manipulation
|
|
||||||
* - Mithril for VDOM and components
|
|
||||||
* - dayjs for date/time operations
|
|
||||||
*
|
|
||||||
* Since these are already part of the global namespace, extensions won't need
|
|
||||||
* to (and should not) bundle these themselves.
|
|
||||||
*/
|
|
||||||
declare global {
|
|
||||||
const $: typeof _$;
|
|
||||||
const m: m;
|
|
||||||
const dayjs: typeof _dayjs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Export Mithril typings globally.
|
|
||||||
*
|
|
||||||
* This lets us use these typings without an extra import everywhere we use
|
|
||||||
* Mithril in a TypeScript file.
|
|
||||||
*/
|
|
||||||
export as namespace Mithril;
|
|
||||||
|
|
||||||
export {};
|
|
@@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"include": ["src/**/*.ts"],
|
|
||||||
"files": ["shims.d.ts"],
|
|
||||||
"compilerOptions": {
|
|
||||||
"allowUmdGlobalAccess": true,
|
|
||||||
"outDir": "dist",
|
|
||||||
"sourceMap": true,
|
|
||||||
"strict": true,
|
|
||||||
"noImplicitReturns": false,
|
|
||||||
"noImplicitAny": false,
|
|
||||||
"module": "es2015",
|
|
||||||
"emitDecoratorMetadata": true,
|
|
||||||
"experimentalDecorators": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"target": "es6",
|
|
||||||
"jsx": "preserve",
|
|
||||||
"lib": ["es2015", "es2017", "dom"],
|
|
||||||
"allowSyntheticDefaultImports": true
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user